const data_sales = [{
        year: '1951 年',
        sales: 38
    },
    {
        year: '1952 年',
        sales: 52
    },
    {
        year: '1956 年',
        sales: 61
    },
    {
        year: '1957 年',
        sales: 145
    },
    {
        year: '1958 年',
        sales: 48
    },
    {
        year: '1959 年',
        sales: 38
    },
    {
        year: '1960 年',
        sales: 38
    },
    {
        year: '1962 年',
        sales: 38
    },
];
const data_city = [{
        value: 63.4,
        city: 'New York',
        date: '2011-10-01'
    },
    {
        value: 62.7,
        city: 'Alaska',
        date: '2011-10-01'
    },
    {
        value: 72.2,
        city: 'Austin',
        date: '2011-10-01'
    },
    {
        value: 58,
        city: 'New York',
        date: '2011-10-02'
    },
    {
        value: 59.9,
        city: 'Alaska',
        date: '2011-10-02'
    },
    {
        value: 67.7,
        city: 'Austin',
        date: '2011-10-02'
    },
    {
        value: 53.3,
        city: 'New York',
        date: '2011-10-03'
    },
    {
        value: 59.1,
        city: 'Alaska',
        date: '2011-10-03'
    },
    {
        value: 69.4,
        city: 'Austin',
        date: '2011-10-03'
    },
];

function modifyDate() {
    const citys = JSON.parse(JSON.stringify(data_city))
    // console.log("data_city", data_city)
    for (let i = 0; i < citys.length; i++) {
        var date = citys[i].date
        citys[i].date = date.replace('10', '11')
    }
    // console.log("data_city", data_city)
    return citys
}

const pre_data = [{
    date: '2019/11/10',
    personNum: 400
}, {
    date: '2019/11/11',
    personNum: 500
}, {
    date: '2019/11/12',
    personNum: 400
}, {
    date: '2019/11/13',
    personNum: 300
}, {
    date: '2019/11/14',
    personNum: 400
}, {
    date: '2019/11/15',
    personNum: 300
}, {
    date: '2019/11/16',
    personNum: 500
}, {
    date: '2019/11/17',
    personNum: 700
}, {
    date: '2019/11/18',
    personNum: 800
}, {
    date: '2019/11/19',
    personNum: 600
}]

const real_data = [{
    date: '2019/11/10',
    personNum: 300
}, {
    date: '2019/11/11',
    personNum: 400
}, {
    date: '2019/11/12',
    personNum: 500
}, {
    date: '2019/11/13',
    personNum: 400
}, {
    date: '2019/11/14',
    personNum: 500
}, {
    date: '2019/11/15',
    personNum: 400
}, {
    date: '2019/11/16',
    personNum: 500
}, {
    date: '2019/11/17',
    personNum: 600
}, {
    date: '2019/11/18',
    personNum: 700
}, {
    date: '2019/11/19',
    personNum: 800
}]
const com_data = [{
    date: '2019/11/10',
    carNum: 4,
    personNum: 380
}, {
    date: '2019/11/11',
    carNum: 5,
    personNum: 450
}, {
    date: '2019/11/12',
    carNum: 6,
    personNum: 580
}, {
    date: '2019/11/13',
    carNum: 7,
    personNum: 640
}, {
    date: '2019/11/14',
    carNum: 6,
    personNum: 570
}, {
    date: '2019/11/15',
    carNum: 4,
    personNum: 350
}, {
    date: '2019/11/16',
    carNum: 5,
    personNum: 420
}, {
    date: '2019/11/17',
    carNum: 6,
    personNum: 540
}, {
    date: '2019/11/18',
    carNum: 5,
    personNum: 450
}, {
    date: '2019/11/19',
    carNum: 4,
    personNum: 340
}]

function modifyYear() {
    const years = JSON.parse(JSON.stringify(data_sales))
    for (let i = 0; i < years.length; i++) {
        var year = years[i].year
        years[i].year = year.replace('年', 'n')
    }
    return years
}

function addType(list, type) {
    var mList = list
    var reg = new RegExp('/', "g")
    for (var i = 0; i < mList.length; i++) {
        var date = mList[i].date.replace(reg, '');
        if (type != null)
            mList[i].type = type;
        mList[i].dateNum = parseInt(date)
    }
    return mList
}

var data_city_m = modifyDate()
var data_sales_m = modifyYear()

var preList = addType(pre_data, '预测')
var realList = addType(real_data, '实际')

const line_data = preList.concat(realList);
const com_data_m = addType(com_data)

module.exports = {
    data_sales,
    data_sales_m,
    data_city,
    data_city_m,
    line_data,
    com_data_m
}